//
// Created by gogoqiu on 2022/2/14.
//

//
// Created by gogoqiu on 2021/10/19.
//

#include "wifi_monitor.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <asm/types.h>
#include <asm/types.h>
#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/if.h>
#include <linux/rtnetlink.h>
#include <stdlib.h>
#include <time.h>
#include <execinfo.h>
#include "CException.h"
#include <wx/snglinst.h>

//handle
void OnSIGSEGV(int signum, siginfo_t *info,void *ptr){
    void * array[25]; /* 25 层，太够了 : )，你也可以自己设定个其他值 */
    int nSize = backtrace(array, sizeof(array)/sizeof(array[0]));
    for (int i=nSize-3; i>=2; i--){ /* 头尾几个地址不必输出，看官要是好奇，输出来看看就知道了 */
        /* 修正array使其指向正在执行的代码 */
        printf("SIGSEGV catched when running code at %x\n", (char*)array[i] - 1);
    }
    abort();
}


/**
 * 定时运行，然后通过wxWidget实现单实体运行
 */
int main(int argc, char** argv) {
    /*
    auto* checker = new wxSingleInstanceChecker();
    if ( checker->IsAnotherRunning()) {
        delete checker;
        checker = nullptr;
        return -1;
    }*/
    TRY
    WifiMonitorAction monitor;
    monitor.Perform();
    END_TRY
    return 0;
}